package com.gitee.xmhzzz.component.shutdown.graceful.service;

import com.gitee.xmhzzz.component.shutdown.graceful.event.ApplicationShutdownEvent;
import com.gitee.xmhzzz.component.shutdown.graceful.event.ApplicationUpEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * @ClassName ShutdownServiceImpl
 * @Description
 * @Author wzq
 * @Date 2023/11/6 9:52
 * @Version 1.0
 */
@Component("shutdownServiceImpl")
public class ShutdownServiceImpl implements IShutdownService {
    private static final Logger log = LoggerFactory.getLogger(ShutdownServiceImpl.class);

    @Autowired
    private ApplicationContext applicationContext;


    @Override
    public void shutdown() {
        applicationContext.publishEvent(new ApplicationShutdownEvent(applicationContext));
    }

    @Override
    public void startup() {
        applicationContext.publishEvent(new ApplicationUpEvent(applicationContext));
    }
}
